<template>
	<view class="goods">
		<view class="top-main"
			style="background-image: url('../../static/images/85f83654638ed1c1c3cebd5abadaa526.jpeg');">
			<view class="top-box" :class="{'show_top': isShowTop}">
				<up-icon @click="onBack" :name="pages.length > 1 ? 'arrow-left' : 'home'" size="22"
					:color="isShowTop ? '#000000' : '#ffffff'"></up-icon>
				<view class="page-title" v-if="isShowTop">日本</view>
				<view style="width: 40rpx;"></view>
			</view>
			<view class="country-box u-flex u-flex-items-end u-flex-between">
				<view class="country-left">
					<view class="country-name">日本 <text class="country-en-name">Japan</text></view>
					<view class="country-qty">已有 183728 人办理</view>
				</view>
				<view class="country-right">
					<up-icon name="calendar-fill" size="22" color="#ffffff"></up-icon>
					<view class="u-m-l-10">领馆日历</view>
				</view>
			</view>
			<view class="notice-box">
				<up-notice-bar :text="noticeList" bgColor="rgba(0,0,0,0)" :speed="100" color="#ffffff" mode="link"
					direction="column" @click="onNoticeJump"></up-notice-bar>
			</view>
		</view>
		<view class="goods-main">
			<view class="location-box u-flex u-flex-items-center u-flex-center">
				<up-icon name="map-fill" size="18" color="#fb5f35"></up-icon>
				<view class="location-text">常住地</view>
				<view class="location-name u-flex u-flex-items-center">
					<view class="u-m-r-10">海南</view>
					<up-icon name="arrow-down" size="14" color="#999999"></up-icon>
				</view>
			</view>
			<up-scroll-list indicatorActiveColor="#fb5f35">
				<view class="filter-box">
					<view class="filter-item" :class="{'active': index === current}"
						v-for="(visa, index) in appStore.visaTypeList" :key="index">{{visa.name}}</view>
				</view>
			</up-scroll-list>

			<up-scroll-list indicatorActiveColor="#fb5f35">
				<view class="filter-box">
					<view class="filter-item2" :class="{'active': index === current2}"
						v-for="(name, index) in typeList2" :key="index">{{name}}</view>
				</view>
			</up-scroll-list>

			<view class="goods-list">
				<view class="goods-item" v-for="item in 10" :key="item" @click="onJumpDetail">
					<view class="goods-item-top">
						<view class="goods-name">
							<view class="name">旅游签</view>
							<view class="goods-tags">
								<view class="tab-item">拒签退全款</view>
								<view class="tab-item">电子签证</view>
							</view>
						</view>
						<view class="goods-price">
							<text class="price">329</text>
							<text class="unit">/人</text>
						</view>
					</view>
					<view class="goods-sub-title">日本 旅游签·三年多次入境【广州领取】下单先咨询·勿提前邮寄·不收急件·福建暂无法办理</view>
					<view class="goods-item-bottom">
						<view class="goods-info">
							<view class="info-item"><up-icon name="clock" size="12" color="#ffcd88"></up-icon> 9~11 个工作日
							</view>
							<view class="info-item"><up-icon name="checkmark-circle" size="12"
									color="#ffcd88"></up-icon>出签率90%</view>
						</view>
						<view class="order-qty">2838 人办理</view>
					</view>
				</view>
			</view>

		</view>


	</view>
</template>

<script setup lang="ts">
	import { ref, onMounted } from "vue";
	import { onPageScroll } from "@dcloudio/uni-app";
	import { useAppStoreHook } from "@/store/modules/app";

	const appStore = useAppStoreHook();

	let isShowTop = ref(false);
	let noticeList = ref(['1111111111111111111111', '222222222222222222222222']);
	let typeList2 = ['全部', '单次入境', '多次入境', '加急', '电子签'];
	let current = 0;
	let current2 = 0;
	let pages = ref([]);

	function onBack() {
		if (pages.value.length > 0) {
			uni.navigateBack();
		} else {
			uni.switchTab({
				url: "/pages/index/index"
			})
		}
	}
	
	function onJumpDetail(){
		uni.navigateTo({
			url: "/pages/goods/detail"
		})
	}
	
	// 点击公告
	function onNoticeJump() {

	}
	// 定义onPageScroll方法
	onPageScroll(({ scrollTop }) => {
		if (scrollTop >= 40) {
			isShowTop.value = true;
		} else {
			isShowTop.value = false;
		}
	});

	onMounted(() => {
		pages.value = getCurrentPages(); // 获取当前打开的页面栈列表
	})
</script>

<style lang="scss" scoped>
	.goods {
		.top-main {
			height: 500rpx;
			background-repeat: no-repeat;
			background-size: 100% 100%;
			position: relative;

			.top-box {
				height: 180rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 30rpx;
				box-sizing: border-box;
				padding-top: calc(var(--status-bar-height) + 40rpx);
				position: fixed;
				left: 0;
				top: 0;
				right: 0;
				z-index: 100;
				background-color: rgba(255, 255, 255, 0);
				transition: all 0.5s ease;
				
				.page-title{
					font-size: 32rpx;
					color: #000;
				}

				&.show_top {
					background-color: rgba(255, 255, 255, 1);
					box-shadow: 0 0 20rpx 2rpx #999999;
				}
			}

			.country-box {
				padding: 200rpx 30rpx 0;

				.country-left {
					.country-name {
						font-size: 42rpx;
						font-weight: bold;
						color: #ffffff;
						display: flex;
						align-items: flex-end;
						margin-bottom: 20rpx;

						.country-en-name {
							font-size: 32rpx;
							font-weight: 400;
							color: #ffffff;
							display: block;
							margin-left: 10rpx;
						}
					}

					.country-qty {
						font-size: 24rpx;
						color: #ffffff;
					}
				}


				.country-right {
					display: flex;
					align-items: center;
					color: #ffffff;
					font-weight: bold;
				}
			}

			.notice-box {
				position: absolute;
				left: 0;
				right: 0;
				bottom: 40rpx;
			}
		}

		.goods-main {
			width: 100%;
			background-color: #ffffff;
			border-radius: 30rpx 30rpx 0 0;
			margin-top: -40rpx;
			position: relative;
			z-index: 50;
			overflow: hidden;

			.location-box {
				padding: 20rpx;
				border-bottom: 2rpx solid #f0f0f0;
				background-color: #ffffff;

				.location-text {
					color: #666666;
					margin: 0 10rpx;
				}
			}

			.filter-box {
				display: flex;
				padding: 20rpx 20rpx 0;

				.filter-item {
					margin: 0 10rpx;
					width: 160rpx;
					height: 70rpx;
					border-radius: 35rpx;
					background-color: #f0f0f0;
					text-align: center;
					line-height: 70rpx;

					&.active {
						background-color: #fb5f35;
						color: #ffffff;
					}
				}

				.filter-item2 {
					width: 140rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					border: 2rpx solid #999999;
					border-radius: 10rpx;
					margin: 0 10rpx;

					&.active {
						border-color: #fb5f35;
						color: #fb5f35;
						background-color: rgba(251, 95, 53, 0.2);
					}
				}

			}

			.goods-list {
				background-color: #f0f0f0;
				padding: 20rpx;

				.goods-item {
					padding: 20rpx;
					border-radius: 20rpx;
					margin-bottom: 20rpx;
					background-color: #ffffff;

					.goods-item-top {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.goods-name {
							display: flex;
							align-items: center;

							.name {
								font-size: 32rpx;
								font-weight: bold;
							}

							.goods-tags {
								display: flex;
								align-items: center;

								.tab-item {
									font-size: 22rpx;
									border: 2rpx solid #f0f0f0;
									padding: 4rpx 10rpx;
									margin-left: 10rpx;
									color: #888104;
									background-color: #f7f6ec;

									&:first-child {
										color: #d808ea;
										background-color: #faf3fb;

									}
								}
							}
						}

						.goods-price {

							.price {
								font-weight: bold;
								color: #ff0000;

								&::before {
									content: "￥";
									font-size: 24rpx;
								}
							}

							.unit {}
						}
					}

					.goods-sub-title {
						font-size: 28rpx;
						margin: 10rpx 0;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}

					.goods-item-bottom {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.goods-info {
							display: flex;
							align-items: center;

							.info-item {
								font-size: 24rpx;
								color: #999999;
								margin-right: 20rpx;
								display: flex;
								align-items: center;
							}
						}

						.order-qty {
							font-size: 24rpx;
							color: #999999;
						}
					}
				}
			}
		}
	}
</style>